# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=tomli
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.2.2
pkgrel=2
pkgdesc="A lil' TOML parser (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://github.com/hukkin/tomli'
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-flit-core")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest" 
              "${MINGW_PACKAGE_PREFIX}-python-dateutil")
source=("${_realname}-$pkgver.tar.gz"::"$url/archive/$pkgver.tar.gz")
sha256sums=('fd61c039272b833214a527d4e20b7e5999986736ee9fc29db55af33272638d03')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  python -m pytest
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
